﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

class CMenu
{

    Texture2D t_ufo, t_control_mouse, t_khung;
    Texture2D t_newgame1, t_loadgame1, t_market, t_help, t_option1, t_exitgame;
    Texture2D t_newgame2, t_loadgame2, t_market2, t_help2, t_option2, t_exitgame2;
    CBackGround backGround;
    CListMenu cListMenu;
    CControlPressButton controlPressButton;
    CControlMouse controlMouse;
    private int i_SelectButton = 0, previ_Select = 0;
    private int m_SelectButton = 0, prevm_Select = 0;
    public bool b_TrangThai = true;
    bool DiChuot = false;

    public void LoadContent( ContentManager Content)
    {

        t_ufo = Content.Load<Texture2D>(@"Img\t_ufo2");
        t_control_mouse = Content.Load<Texture2D>(@"Img\control_mouse");
        t_khung = Content.Load<Texture2D>(@"Img\ImgListMenu\khung8");

        t_newgame1 = Content.Load<Texture2D>(@"Img\ImgListMenu\newgame1");
        t_loadgame1 = Content.Load<Texture2D>(@"Img\ImgListMenu\loadgame1");
        t_market = Content.Load<Texture2D>(@"Img\ImgListMenu\market");
        t_help = Content.Load<Texture2D>(@"Img\ImgListMenu\help");
        t_option1 = Content.Load<Texture2D>(@"Img\ImgListMenu\Option1");
        t_exitgame = Content.Load<Texture2D>(@"Img\ImgListMenu\exitgame");

        t_newgame2 = Content.Load<Texture2D>(@"Img\ImgListMenu\newgame2");
        t_loadgame2 = Content.Load<Texture2D>(@"Img\ImgListMenu\loadgame2");
        t_market2 = Content.Load<Texture2D>(@"Img\ImgListMenu\market2");
        t_help2 = Content.Load<Texture2D>(@"Img\ImgListMenu\help2");
        t_option2 = Content.Load<Texture2D>(@"Img\ImgListMenu\Option2");
        t_exitgame2 = Content.Load<Texture2D>(@"Img\ImgListMenu\exitgame2");

        backGround = new CBackGround();
        cListMenu = new CListMenu();
        controlMouse = new CControlMouse();
        controlPressButton = new CControlPressButton();
    }
    public void Update(Game game)
    {
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            game.Exit();
        DiChuot = controlMouse.DiChuot();
        if (DiChuot == true)
            m_SelectButton = controlMouse.selectButton(m_SelectButton, t_newgame1);
        m_SelectButton = controlPressButton.selectButton(m_SelectButton);

        if (DiChuot == true)
            b_TrangThai = controlMouse.Check(b_TrangThai);
        b_TrangThai = controlPressButton.Check(b_TrangThai);

        controlMouse.Update(game);
        controlPressButton.Update(game);
    }
    public void Draw(SpriteBatch spriteBatch)
    {
        backGround.Draw(spriteBatch, t_ufo);

        cListMenu.DrawFirst(spriteBatch, t_newgame1, 0);
        cListMenu.DrawFirst(spriteBatch, t_loadgame1, 1);
        cListMenu.DrawFirst(spriteBatch, t_market, 2);
        cListMenu.DrawFirst(spriteBatch, t_help, 3);
        cListMenu.DrawFirst(spriteBatch, t_option1, 4);
        cListMenu.DrawFirst(spriteBatch, t_exitgame, 5);

        if (b_TrangThai == true)
        {
            cListMenu.Draw(spriteBatch, t_newgame1, t_newgame2, 0, m_SelectButton);
            cListMenu.Draw(spriteBatch, t_loadgame1, t_loadgame2, 1, m_SelectButton);
            cListMenu.Draw(spriteBatch, t_market, t_market2, 2, m_SelectButton);
            cListMenu.Draw(spriteBatch, t_help, t_help2, 3, m_SelectButton);
            cListMenu.Draw(spriteBatch, t_option1, t_option2, 4, m_SelectButton);
            cListMenu.Draw(spriteBatch, t_exitgame, t_exitgame2, 5, m_SelectButton);
        }

        if (b_TrangThai == false)
            controlMouse.Draw(spriteBatch, t_khung, t_newgame1, m_SelectButton);

        controlMouse.ShowMouse(spriteBatch, t_control_mouse);
    }
}

